package com.hbm.usercenter.holder;

import android.view.View;
import android.widget.LinearLayout;

import com.hbm.usercenter.R;
import com.hbm.usercenter.base.BaseHolder;
import com.hbm.usercenter.utils.UIUtils;

import butterknife.Bind;
import butterknife.ButterKnife;

public class LoadMoreHolder extends BaseHolder<Integer> {


    public static final int STATE_LOADING = 1;    // 显示加载效果
    public static final int STATE_RETRY = 2;    // 显示重试效果
    public static final int STATE_EMPTY = 3;    // 没有加载更多,两个都不显示

    @Bind(R.id.item_loadmore_container_loading)
    LinearLayout mContainerLoading;
    @Bind(R.id.item_loadmore_container_retry)
    LinearLayout mContainerRetry;

    @Override
    protected View initHolderView() {
        View view = View.inflate(UIUtils.getContext(), R.layout.item_loadmore, null);
        ButterKnife.bind(this,view);
        return view;
    }

    @Override
    protected void refreshHolderView(Integer state) {
        mContainerLoading.setVisibility(View.INVISIBLE);
        mContainerRetry.setVisibility(View.INVISIBLE);
        switch (state) {
            case STATE_LOADING:
                mContainerLoading.setVisibility(View.VISIBLE);
                break;
            case STATE_RETRY:
                mContainerRetry.setVisibility(View.INVISIBLE);
                break;
            case STATE_EMPTY:
                mContainerLoading.setVisibility(View.GONE);
                mContainerRetry.setVisibility(View.GONE);
                break;

            default:
                break;
        }
    }

}
